<template>
  <h1>这是父组件，名字叫{{ name }}</h1>
  <button type="button" @click="valueAdd">
    count is: {{ state.count }}
  </button>
  <hr/>  
  <van-uploader :after-read="afterRead">
   <img :src="img" alt="" class="head">
</van-uploader>
</template>

<script setup> 
import Test from './Son.vue'; 

import {ref, reactive, onMounted} from 'vue'
import {onBeforeRouteLeave, useRoute, useRouter} from "vue-router";
const router = useRouter()
const route = useRoute()
const name = ref('张三')
const img = ref('head.png')
const state = reactive({count: 0})  

const valueAdd = () => { state.count++ } 
const toFather = (value) => { 
    router.push({name:'home',params:{id:value}}) 
}

const afterRead = (file) => {
      // 此时可以自行将文件上传至服务器
     console.log(file);
     img.value = file.content
}; 
</script>

<style scoped>
.head {
  width: 100px;
  height: 100px;
}
</style>
